home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************
-
- File: ISpPlugInUI.h
-
- Copyright © 1996, 1997, 1998 Apple Computer, Inc., All Rights Reserved
-
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-
- *************************************************************************************/
-
-
- #ifndef __ISPPLUGINUI__
- #define __ISPPLUGINUI__
-
- #ifndef __MACTYPES__
- #include <MacTypes.h>
- #endif
-
- #ifndef __EVENTS__
- #include <Events.h>
- #endif
-
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
-
- #ifndef __INPUTSPROCKET__
- #include <InputSprocket.h>
- #endif
-
- #include "InputSprocketDriver.h"
-
- enum { kMenuID_TempMenu = -1 };
-
- // plugin string list
- enum
- {
- kStrList_PlugInUI = 50,
- kStrList_PlugInUI_None = 1
- };
-
- // 'isei' resources
- enum
- {
- kElementConfigResource_BlankDPad = 128,
- kElementConfigResource_DPad1 = 129,
- kElementConfigResource_BlankButton = 130,
- kElementConfigResource_Button1 = 131,
- kElementConfigResource_SymetricAxis = 132,
- kElementConfigResource_AsymetricAxis = 133,
- kElementConfigResource_Delta = 134,
- kElementConfigResource_Button2 = 135
- };
-
- // classs definition
- class ISpPlugInUI
- {
- public:
- ISpPlugInUI (void);
-
- // these must be overridden in the subclass
- virtual OSStatus Init( UInt32 count,
- ISpNeed needs[],
- ISpElementReference virtualElements[],
- Boolean used[],
- OSType appCreatorCode,
- OSType subCreatorCode,
- UInt32 stateLength,
- void *state) = 0;
- virtual OSStatus Stop(void) = 0;
- virtual OSStatus GetSize(Point &minimum, Point &best) = 0;
- virtual OSStatus HandleEvent(EventRecord &theEvent, Boolean &handled) = 0;
- virtual OSStatus Show(DialogPtr theDialog, short dialogItemNumber, Rect &r) = 0;
- virtual OSStatus Hide(void) = 0;
- virtual OSStatus BeginConfiguration(UInt32 count, ISpNeed needs[]) = 0;
- virtual OSStatus EndConfiguration(Boolean accept) = 0;
- virtual OSStatus GetIcon(short &iconSuiteResourceId) = 0;
- virtual OSStatus GetState(UInt32 buflen, void *buffer, UInt32 &length) = 0;
- virtual OSStatus SetState(UInt32 length, void *buffer) = 0;
- virtual OSStatus Dirty(Boolean &dirty);
- virtual OSStatus SetActive(Boolean active) = 0;
- virtual OSStatus DialogItemHit(short itemHit) = 0;
-
- // 1.03 or later stuff
- virtual OSStatus Tickle(void) = 0;
- virtual OSStatus InterruptTickle(void) = 0;
- virtual OSStatus Draw(void) = 0;
- virtual OSStatus Click(const EventRecord &event) = 0;
-
- // 1.2 or later stuff
- virtual OSStatus ADBReInit(Boolean inPostProcess) = 0;
-
- // metahandler
- static ISpDriverFunctionPtr_Generic MetaHandler(UInt32 refCon, ISpMetaHandlerSelector selector);
-
- // common UI
- protected:
- enum { kUnsetIndex = 0xffff0001 };
-
- // !!! ISpDriverBase has descended from ISPPlugInUI and handles everything that has been
- // !!! recently added to this class, and much more. These classes need to be reconciled
- // !!! but for now, this eliminates duplicated member caruables
- ISpElementReference * mReferences;
- ISpNeed * mNeeds;
- UInt32 mNumNeeds;
-
- DialogPtr mDialog;
- short mBaseDITLCount;
-
- Boolean mDirty;
-
- virtual UInt32 * GetDialogItemToNeedMapping () = 0;
- virtual void SetVirtualElements (void) = 0; // was SetFromIndex
- virtual Boolean IsPressed (short inDialogItem) {inDialogItem; return false;}; // is this dialog item 'pressed' (ie on the device)
-
- public:
- typedef enum
- {
- kDirection_None,
- kDirection_X,
- kDirection_Y,
- kDirection_Z,
- kDirection_Rx,
- kDirection_Ry,
- kDirection_Rz,
-
- kDirection_Roll = kDirection_Rz,
- kDirection_Pitch = kDirection_Rx,
- kDirection_Yaw = kDirection_Ry
- } DirectionType;
-
- static DirectionType GetDirection2D(ISpElementLabel label);
- static DirectionType GetDirection(ISpElementLabel label);
-
- private:
- Boolean CheckPopUpHit(
- Point inWhere,
- short inDialogItem,
- ISpElementKind elementKind,
- ISpElementLabel elementLabel,
- ISpElementKind *validKinds,
- UInt32 numKinds,
- UInt32 inNeed,
- UInt32 &outNeed);
-
-
- Boolean IsAppropriateNeedForButton(
- ISpNeed & need,
- ISpElementLabel buttonLabel);
-
- Boolean IsAppropriateNeedForDPad(
- ISpNeed & need,
- ISpElementLabel dpadLabel);
-
- Boolean IsAppropriateNeedForAxis(
- ISpNeed & need,
- ISpElementLabel axisLabel);
-
- Boolean IsAppropriateNeedForDelta(
- ISpNeed & need,
- ISpElementLabel deltaLabel);
-
- Boolean IsAppropriateNeed(
- ISpNeed & need,
- ISpElementKind elementKind,
- ISpElementLabel elementLabel);
-
- protected:
- void SetDialogControl(
- short inRelDialogItem,
- short inValue);
-
- void PlotPopupIcon(
- short inItem,
- IconTransformType inTransform);
-
- void HandleStickClick (
- Point where,
- short dialogItem,
- UInt32 upDialogItem,
- UInt32 downDialogItem,
- UInt32 leftDialogItem,
- UInt32 rightDialogItem,
- UInt32 oldNeed,
- UInt32 &newNeed);
-
- void HandleMouseClick (
- Point where,
- short dialogItem,
- UInt32 upDialogItem,
- UInt32 downDialogItem,
- UInt32 leftDialogItem,
- UInt32 rightDialogItem,
- UInt32 oldNeed,
- UInt32 &newNeed);
-
- void HandleDeltaClick (
- Point where,
- short dialogItem,
- ISpElementLabel elementLabel,
- UInt32 minDeltaDialogItem,
- UInt32 maxDeltaDialogItem,
- UInt32 oldNeed,
- UInt32 &newNeed);
-
- void HandleAxisClick (
- Point where,
- short dialogItem,
- ISpElementLabel elementLabel,
- UInt32 minAxisDialogItem,
- UInt32 maxAxisDialogItem,
- UInt32 oldNeed,
- UInt32 &newNeed);
-
- void HandlePedalAxisClick (
- Point where,
- short dialogItem,
- ISpElementLabel elementLabel,
- UInt32 oldNeed,
- UInt32 &newNeed);
-
- void HandleButtonClick (
- Point where,
- short dialogItem,
- ISpElementLabel elementLabel,
- UInt32 oldNeed,
- UInt32 &newNeed);
-
- void HandleDPadClick (
- Point where,
- short dialogItem,
- UInt32 upDialogItem,
- UInt32 downDialogItem,
- UInt32 leftDialogItem,
- UInt32 rightDialogItem,
- UInt32 oldNeed,
- UInt32 &newNeed);
-
-
- private:
- static OSStatus MHInit( UInt32 refCon,
- UInt32 count,
- ISpNeed needs[],
- ISpElementReference virtualElements[],
- Boolean used[],
- OSType appCreatorCode,
- OSType subCreatorCode,
- UInt32 reserved,
- void* reserved2);
- static OSStatus MHStop(UInt32 refCon);
- static OSStatus MHGetSize(UInt32 refCon, Point *minimum, Point *best);
- static OSStatus MHHandleEvent(UInt32 refCon, EventRecord *theEvent, Boolean *handled);
- static OSStatus MHShow(UInt32 refCon, DialogPtr theDialog, short dialogItemNumber, Rect *r);
- static OSStatus MHHide(UInt32 refCon);
- static OSStatus MHBeginConfiguration(UInt32 refCon, UInt32 count, ISpNeed needs[]);
- static OSStatus MHEndConfiguration(UInt32 refCon, Boolean accept);
- static OSStatus MHGetIcon(UInt32 refCon, short *iconSuiteResourceId);
- static OSStatus MHGetState(UInt32 refCon, UInt32 buflen, void *buffer, UInt32 *length);
- static OSStatus MHSetState(UInt32 refCon, UInt32 length, void *buffer);
- static OSStatus MHDirty(UInt32 refCon, Boolean *dirty);
- static OSStatus MHSetActive(UInt32 refCon, Boolean active);
- static OSStatus MHDialogItemHit(UInt32 refCon, short itemHit);
-
- // 1.03 or later stuff
- static OSStatus MHTickle(UInt32 refCon);
- static OSStatus MHInterruptTickle(UInt32 refCon);
- static OSStatus MHDraw(UInt32 refCon);
- static OSStatus MHClick(UInt32 refCon, const EventRecord *event);
-
- // 1.2 or later stuff
- static OSStatus MHADBReInit(UInt32 refCon, Boolean inPostProcess);
-
- #if FORCE_FB
- //• Force Effect Functions
- static OSStatus MHBuffeting(UInt32 refCon, UInt32 inMagnitude);
- static OSStatus MHBuffetingClear(UInt32 refCon);
- static OSStatus MHButtonReflexJolt(UInt32 refCon, UInt32 inButton, UInt32 inMagnitude, SInt32 inDirection, UInt32 inDuration, UInt32 inRepeatRate);
- static OSStatus MHButtonReflexClear(UInt32 refCon, UInt32 inButton);
- static OSStatus MHJolt(UInt32 refCon, UInt32 inMagnitude, SInt32 inDirection, UInt32 inDuration);
- static OSStatus MHXVibration(UInt32 refCon, UInt32 inLeftMagnitude, UInt32 inRightMagnitude, UInt32 inFrequency);
- static OSStatus MHXVibrationClear(UInt32 refCon);
- static OSStatus MHYVibration(UInt32 refCon, UInt32 inUpMagnitude, UInt32 inDownMagnitude, UInt32 inFrequency);
- static OSStatus MHYVibrationClear(UInt32 refCon);
- static OSStatus MHVectorForce(UInt32 refCon, UInt32 inMagnitude, SInt32 inDirection);
- static OSStatus MHVectorForceClear(UInt32 refCon);
- static OSStatus MHXYVectorForce(UInt32 refCon, SInt32 inXMagnitude, SInt32 inYMagnitude);
- static OSStatus MHXSpring(UInt32 refCon, SInt32 inOrigin, UInt32 inLeftStiffness, UInt32 inRightStiffness);
- static OSStatus MHXSpringClear(UInt32 refCon);
- static OSStatus MHYSpring(UInt32 refCon, SInt32 inOrigin, UInt32 inUpStiffness, UInt32 inDownStiffness);
- static OSStatus MHYSpringClear(UInt32 refCon);
- #endif
-
- unsigned long thumbprint;
-
- enum
- {
- kThumbprint = 'ispx'
- };
- };
-
- OSStatus CreateDeviceFromResource( short resId,
- UInt32 refCon,
- ISpDeviceReference &device);
-
- OSStatus CreateElementFromResource( short elementResId,
- short configResID,
- ISpDeviceReference device,
- ISpElementReference &element);
-
- void MakeDialogItemInvisable (DialogRef theDialog, short itemNo);
- Boolean DialogItemIsInvisable (DialogRef theDialog, short itemNo);
- void SetDialogItemWidth (DialogRef theDialog, short itemNo, short width);
-
- enum
- {
- kAxisAsButton_Left = 0,
- kAxisAsButton_Right = 1,
- kAxisAsButton_Down = 0,
- kAxisAsButton_Up = 1,
- kAxisAsButton_Min = 0,
- kAxisAsButton_Max = 1
- };
-
- void AxisToButtons(UInt32 axis, UInt32 buttons[2]); //SetAxisButtons
- void PedalAxisToButton(UInt32 axis, UInt32 & button);//PedalAxisToButton
- UInt32 AxisToDPad(UInt32 xAxis, UInt32 yAxis); //SetAxisDPad
- UInt32 BooleanDirectionsToDPad(UInt32 up, UInt32 left, UInt32 down, UInt32 right);
- UInt32 DigitalAxisToDPad(SInt8 x, SInt8 y);
- void DPadToButtonsAndAxis(UInt32 dpad, UInt32 buttons[4], UInt32 axis[2]);//SetDPadAsButtonsAndAxis
- UInt32 DPadReverseVertical(UInt32 dpad);
-
- #endif /* __ISPPLUGINUI__ */
-